//          https://ac.nowcoder.com/acm/contest/61570/C


#include <iostream>
using namespace std;

typedef long long LL;

int main()
{
    LL n, m, a, b, ans;
    cin >> n >> m >> a >> b;
    if ((n == m && n == 1 && m == 1) || n == 0 || m == 0)
    {
        cout << "0" << endl;
        return 0;
    }
    else
    {
        for (int i = 0; 2 * i <= n && i <= m; i++)
        {
            LL x = n - i * 2;
            LL y = m - i;
            LL j = min(x, y / 2);
            LL sum = i * a + j * b;
            ans = max(ans, sum);
        }
        cout << ans << endl;
        return 0;
    }
}